package com.mooc.yohoshop.ui.splash;

import android.content.Intent;

import com.blankj.utilcode.util.SPUtils;
import com.mooc.yohoshop.R;
import com.mooc.yohoshop.entity.BaseEntity;
import com.mooc.yohoshop.entity.TokenEntity;
import com.mooc.yohoshop.ui.frame.MainActivity;
import com.mooc.yohoshop.ui.base.BaseActivity;

import java.util.HashMap;

public class SplashActivity extends BaseActivity<SplashRepo> {

    @Override
    protected int layout() {
        return R.layout.activity_splash;
    }

    @Override
    protected void init() {
    }

    @Override
    protected void initData() {
        HashMap<String,String>map=new HashMap<>();
        map.put("imie",""+System.currentTimeMillis());
        request(repo.requestToken(map));
    }

    @Override
    protected void result(BaseEntity baseEntity) {
        TokenEntity tokenEntity = (TokenEntity) baseEntity;
        SPUtils.getInstance().put("token",tokenEntity.data.token);
        startActivity(new Intent(this, MainActivity.class));
        finish();
    }
}
